<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>WithDrawal Form</title>
<link rel="stylesheet" type="text/css" href="css/style-old11.css" />
<link rel="stylesheet" type="text/css" href="css/withdrawal.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script type="text/javascript" src="js/ddaccordion.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="css/niceforms-default.css" />
<script type="text/javascript">
	ddaccordion.init({
		headerclass: "submenuheader", 
		contentclass: "submenu", 
		revealtype: "click", 
		mouseoverdelay: 200,
		collapseprev: true, 
		defaultexpanded: [], 
		onemustopen: false, 
		animatedefault: false,
		persiststate: true, 
		toggleclass: ["", ""], 
		togglehtml: ["suffix", "<img src='images/plus.gif' class='statusicon' />", "<img src='images/minus.gif' class='statusicon' />"],
		animatespeed: "fast", 
		oninit:function(headers, expandedindices){ 
		},
		onopenclose:function(header, index, state, isuseractivated){ 
		}
	});

	$(document).ready(function() {
		
		
		 $.ajax({
				url : './user/getUserDetail',
				dataType: "json",
				contentType: 'application/json',			    
				success : function(jsonData) {
						for(var a in jsonData){
						document.getElementById("bname").value=jsonData[a]["bname"];
						document.getElementById("accno").value=jsonData[a]["accno"];
						document.getElementById("emailid").value=jsonData[a]["emailID"];
						document.getElementById("fname").value=jsonData[a]["fname"]+" "+jsonData[a]["lname"];
						document.getElementById("ifsc").value=jsonData[a]["ifsc"];
						
						
					}
						}
			});
			
	   $("#send").click(function(event) {
			var req=0;

			 if(document.getElementById('pnameErrorLable').innerHTML!=""){
				req=1;
			}
			 else if(document.getElementById('ifscErrorLable').innerHTML!=""){
					req=1;
				}
			 else if(document.getElementById('bnameErrorLable').innerHTML!=""){
					req=1;
				}
			 else if(document.getElementById('wmodeErrorLable').innerHTML!=""){
					req=1;
				}
			 else if(document.getElementById('accnoErrorLable').innerHTML!=""){
					req=1;
				}
			 else if(document.getElementById('umailErrorLable').innerHTML!=""){
					req=1;
				}
			 else if(document.getElementById('amountErrorLable').innerHTML!=""){
					req=1;
				}
			
			
			
			if(req==0){
			var reqUrl="./bank/withdraw";
			var jsondata = JSON.stringify({"fname":$("#fname").val(),"emailid":$("#emailid").val(),"ifsc":$("#ifsc").val(),
				"accno":$("#accno").val(),"bname":$("#bname").val(),"w_mode":$("#w_mode").val(),"amount":$("#amount").val(),
				"comments":$("#comments").val()});

		$.ajax(
			  {
			  type: "POST",
			  url: reqUrl,
			  dataType: "json",
			  contentType: 'application/json',			  
			  data:jsondata, 
			  success: function(jsonResponse) { 	
				  alert(jsonResponse["msg"]);
				  document.getElementById("fname").value="";
				  document.getElementById("emailid").value="";
				  document.getElementById("ifsc").value="";
				  document.getElementById("accno").value="";
				  document.getElementById("bname").value=" ";
				  document.getElementById("w_mode").value="";
				  document.getElementById("amount").value="";
				  document.getElementById("transpwd").value=" ";
				  document.getElementById("comments").value="";
			  }
			});
		 event.preventDefaults();
			}
		
	});
	});
	
	function prof()
	{
	if (container1.style.display=="none") container1.style.display="block"; 
	else container1.style.display="block";
	}



	function displayTime() {
	    var elt = document.getElementById("clock");  
	    var now = new Date();                        
	    elt.innerHTML = now.toLocaleTimeString();    
	    setTimeout(displayTime, 1000);               
	}
	window.onload = displayTime;  

function formvalidation(){
	
	var error	=	false;
	document.getElementById('pnameErrorLable').innerHTML="";
	document.getElementById('ifscErrorLable').innerHTML="";
	document.getElementById('bnameErrorLable').innerHTML="";
	document.getElementById('accnoErrorLable').innerHTML="";
	document.getElementById('umailErrorLable').innerHTML="";
	document.getElementById('amountErrorLable').innerHTML="";
	document.getElementById('wmodeErrorLable').innerHTML="";
		
		 if((document.getElementById('emailid').value)==''){
			document.getElementById('umailErrorLable').innerHTML='*Enter  E-mail id.';
			error	=	true;
		}
			if((document.getElementById('fname').value)==''){
			document.getElementById('pnameErrorLable').innerHTML='*Enter First name.';
			error	=	true;
		}
			
			if((document.getElementById('ifsc').value)==''){
				document.getElementById('ifscErrorLable').innerHTML='*Enter IFSC Code.';
				error	=	true;
			}
			if((document.getElementById('accno').value)==''){
				document.getElementById('accnoErrorLable').innerHTML='*Enter Account Number.';
				error	=	true;
			}
			if((document.getElementById('bname').value)==''){
				document.getElementById('bnameErrorLable').innerHTML='*Enter  Bank Name.';
				error	=	true;
			}
			if((document.getElementById('amount').value)==''){
				document.getElementById('amountErrorLable').innerHTML='*Enter Amount.';
				error	=	true;
			}
			if((document.getElementById('w_mode').value)=="Unknown"){
				document.getElementById('wmodeErrorLable').innerHTML='*Select any payment mode.';
				error	=	true;
			}
		
		if(error==false){
			return true;
			}else{ 
			return false;
		}
}

function isNumberKey(evt){
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;
}
</script>


</head>
<body>
<%@ include file="header.jsp" %>	
<div id="main_container">
	
    
    <div class="main_content">    
                    <div class="menu">                    
                    <ul>
                    <li>LoginID : <sec:authentication property="principal.username" /></li>
                    <li><a href="#">Exchange :
                       <select style="height:15px;font-size:9px;"><option>NMCEX</option></select></a>
                    
                    </li>
                    <li><a href="#">Login Type : Client</a>
                     </li>
                    <li><a href="#">Segment : <select style="height:16px;font-size:9px;"><option>commodity mkt(13-14)</option></select></a>
                       
                    </li>                  
                    </ul>
                    </div>                
                    
                    
    <div class="center_content">     
    <div class="left_content">    
    		<div class="sidebar_search">
            <form>
            <input type="text" name="" class="search_input" value="search keyword" onclick="this.value=''" />
            <input type="image" class="search_submit" src="images/search.png" style="width:17px;height:15px;" />
            </form>            
            </div>    
            <div class="sidebarmenu">            
                <a class="menuitem submenuheader" href="">Profile</a>
                <div class="submenu">
                    <ul>
                    <li onclick="prof('container1');"><a href="clientpage">Directory</a></li>               
                    </ul>
                </div>
                <a class="menuitem submenuheader" href="" >Financial</a>
                <div class="submenu">
                    <ul>
                    <li><a href="drcr">Dr./Cr. Summary</a></li>
                    <li><a href="fenlgr">Financial Ledger</a></li>
                    <!-- <li><a href="agingreport">Ageing</a></li> -->                    
                    </ul>
                </div>
                <a class="menuitem submenuheader" href="">Reports</a>
                <div class="submenu">
                    <ul>
                    <li><a href="tradeconf">Trade Conf.</a></li>
                    <li><a href="netpos">N.Pos(As on)</a></li>
                    <li><a href="clientport">PortFolio</a></li>
                    <li><a href="bills">Bills</a></li>                    
                    </ul>
                </div>
                <a class="menuitem submenuheader" href="">Downloads</a>
                 <div class="submenu">
                    <ul>
                   <li><a href="pdf/oct_hn.pdf">Downloads</a></li>
                    <li><a href="pdf/TB_Trading_Regulations.pdf">Reports</a></li>
                    <li><a href="csv/test5.csv">Digital</a></li>
                     </ul>
                </div>
                <a class="menuitem submenuheader" href="">Request</a>
                 <div class="submenu">
                    <ul>
                     <li ><a href="withdrawal">WithDrawal Request</a></li>
                    <li ><a href="clientfundview">Client Fund View</a></li>
                    <li ><a href="fundTransfer">Fund Transfer</a></li>
                    </ul>
                </div>
                <a class="menuitem submenuheader" href="">Admin Panel</a>
                 <div class="submenu">
                    <ul>
                   <li ><a href="nepalholiday">Nepal Holiday List</a></li>
                    </ul>
                </div>
               <a class="menuitem submenuheader" href="">Settings</a>
                 <div class="submenu">
                    <ul>
                    <li ><a href="changepwd">Password Change</a></li>
                    <li ><a href="transactionpwd">Transaction Password Change</a></li>
                    </ul>
                </div>                    
            </div>   
    </div>  
   
    <div id="container1" class="right_content" >            

	<h2>Withdrawal Form</h2>
	    <p>To withdraw funds from your account, please complete and submit the form below.<br/>

           A withdrawal request will be processed only if you have sufficient available funds. If you traded today, the funds will not be available to withdrawal until the following business day.<br/>
			
			Please note: In accordance with anti-money laundering regulations, all withdrawals will be sent from the name on the account.</p>
          
		 <form  method="post" name="withdraw" id="withdraw" class="form"  action="./withdrawal" accept-charset="UTF-8"> 
		
			
			<div class="name" id="field1">
	        	<div class="field2">
				<label for="name" class="label-field">ClientID</label> <sec:authentication property="principal.username" />
				</div>
	            <div class="field2">
				<label for="name" class="label-field1">Client Name<b><font color="red" size="3">*</font></b></label> 
				<input type="text" name="fname" id="fname" placeholder="Enter your last name" required/>
	           	<div id="pnameErrorLable" style="text-align: right;"></div>
	            </div>
			</div>
			<div class="name" id="field1">
	        
	        	<div class="field2">
				<label for="name" class="label-field">Email<b><font color="red" size="3">*</font></b></label>
				 <input type="text" name="emailid" id="emailid" placeholder="mail@example.com" required />
				 	<div id="umailErrorLable" style="text-align: right;"></div>
	            </div>
	            
	            <div class="field2">
				<label for="name" class="label-field1">IFSC CODE<b><font color="red" size="3">*</font></b></label> 
				<input type="text" name="ifsc" id="ifsc" placeholder="Enter IFSC Code"  required />
				<div id="ifscErrorLable" style="text-align: right;"></div>
	            </div>
			</div>
					
			<div class="web" id="field1">
	        	<div class="field2">
					<label for="web" class="label-field">Bank Account Number<b><font color="red" size="3">*</font></b></label> 
					<input type="text" name="accno" id="accno" placeholder="Your account number" onkeypress="return isNumberKey(event)" required/>
					<div id="accnoErrorLable" style="text-align: right;"></div>
				</div>
	            
	            <div class="field2">
					<label for="email" class="label-field1">Bank Name<b><font color="red" size="3">*</font></b></label>
	                	<input type="text" name="bname" id="bname" placeholder="Your Bank Name" required/>
	                	<div id="bnameErrorLable" style="text-align: right;"></div>
				</div>
			</div>	
	        
	        <div class="web" id="field1">
	        	<div class="field2">
					<label for="web" class="label-field">Amount<b><font color="red" size="3">*</font></b></label> 
					<input type="text" name="amount" id="amount" placeholder="Enter Amount" onkeypress="return isNumberKey(event)" required/>
					<div id="amountErrorLable" style="text-align: right;"></div>
				</div>
	            
	            <div class="field2">
					<label for="email" class="label-field1">Currency</label>
					<select name="currency" class="select">
	                    <option>NPR</option>
	                  
	               </select>
				</div>
			</div>	
	        
	       
	        
	        <div class="web" id="field1">
				<div class="field2">
	            <label for="email" class="label-field">Withdrawal Method<b><font color="red" size="3">*</font></b></label> 
				<select id="w_mode" onchange="" style="margin-left:0;margin-right:5px;width:219px;border:1px solid #D6D8DA; height:30px; padding:5px; font-size:12px; color:#333333;" name="idproof">
	                        <option value="Check">Check (sent to address on file)</option>
	                       
	                   </select>
	                 
	                <div id="wmodeErrorLable"></div>  </div>
			</div>
		
			<div class="text" id="field1">
				<label for="email" class="label-field">Additional Comments </label>
				<textarea name="text" placeholder="Write something to us" id="comments" ></textarea>
			</div>
		</div>	
        
        
			<div class="submit" id="field1" style="margin-left:267px">
				<input type="button" value="Send" id="send" name="send" onclick="formvalidation();"/>
			</div>

	 </form>
   
  </div>           
    
    <div class="clear"></div>
    </div> 
   </div> 
    <div class="footer" style="margin-left:25px;">
    
    	<div class="left_footer">Copyright&copy; All Right Reserved</div>
    	<div class="right_footer"><img src="" alt="" title="" border="0" /></div>
    
    </div>

</div>		
</body>
</html>